package com.gzlg.hospital.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gzlg.hospital.dao.AdminDao;
import com.gzlg.hospital.pojo.*;
import com.gzlg.hospital.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDao adminDao;


    @Override
    public Admin adminlogin(String account) {
        return adminDao.adminlogin(account);
    }


    // 医生管理
    @Override
    public List<Doctor> findAllDoctors() {
        return adminDao.findAllDoctors();
    }

    @Override
    public Doctor findDoctorById(Integer id) {
        return adminDao.findDoctorById(id);
    }

    @Override
    public void saveDoctor(Doctor doctor) {
        adminDao.saveDoctor(doctor);
    }

    @Override
    public void updateDoctor(Doctor doctor) {
        adminDao.updateDoctor(doctor);
    }

    @Override
    public void deleteDoctorById(Integer id) {
        adminDao.deleteDoctorById(id);
    }

    @Override
    public List<Doctor> findDoctorsByNameAndIdCard(String name, String id_card) {
        return adminDao.findDoctorsByNameAndIdCard(name, id_card);
    }



    // 患者管理
    @Override
    public List<Patient> findAllPatients() {
        return adminDao.findAllPatients();
    }

    @Override
    public Patient findPatientById(Integer id) {
        return adminDao.findPatientById(id);
    }

    @Override
    public void savePatient(Patient patient) {
        adminDao.savePatient(patient);
    }

    @Override
    public void updatePatient(Patient patient) {
        adminDao.updatePatient(patient);
    }

    @Override
    public void deletePatientById(Integer id) {
        adminDao.deletePatientById(id);
    }

    @Override
    public List<Patient> findPatientsByNameAndIdCard(String name, String id_card) {
        return adminDao.findPatientsByNameAndIdCard(name, id_card);
    }



    // 药品管理
    @Override
    public List<Pharmaceutical> findAllPharmaceuticals() {
        PageInfo<Pharmaceutical> pageInfo = PageInfo.of(adminDao.findAllPharmaceuticals());
        return adminDao.findAllPharmaceuticals();
    }

    @Override
    public Pharmaceutical findPharmaceuticalById(Integer id) {
        return adminDao.findPharmaceuticalById(id);
    }

    @Override
    public void savePharmaceutical(Pharmaceutical pharmaceutical) {
        adminDao.savePharmaceutical(pharmaceutical);
    }

    @Override
    public void updatePharmaceutical(Pharmaceutical pharmaceutical) {
        adminDao.updatePharmaceutical(pharmaceutical);
    }

    @Override
    public void deletePharmaceuticalById(Integer id) {
        adminDao.deletePharmaceuticalById(id);
    }

    @Override
    public List<Pharmaceutical> findPharmaceuticalsByNameAndManufacturer(String name, String manufacturer) {
        return adminDao.findPharmaceuticalsByNameAndManufacturer(name, manufacturer);
    }

    // 床位管理
    @Override
    public List<Bed> findAllBeds() {
        return adminDao.findAllBeds();
    }

    @Override
    public Bed findBedById(int id) {
        return adminDao.findBedById(id);
    }

    @Override
    public void saveBed(Bed bed) {
        adminDao.saveBed(bed);
    }

    @Override
    public void updateBed(Bed bed) {
        adminDao.updateBed(bed);
    }

    @Override
    public void deleteBedById(int id) {
        adminDao.deleteBedById(id);
    }

    @Override
    public List<Bed> findBedsByRoomNumber(String roomNumber) {
        return adminDao.findBedsByRoomNumber(roomNumber);
    }



    // 排班管理
    @Override
    public List<Schedule> findAllSchedules() {
        return adminDao.findAllSchedules();
    }
    @Override
    public List<String> getAllDepartments() {
        return adminDao.getAllDepartments();
    }
    @Override
    public void saveSchedule(Schedule schedule) {
        adminDao.saveSchedule(schedule);
    }

    @Override
    public void deleteScheduleById(Integer id) {
        adminDao.deleteScheduleById(id);
    }
    @Override
    public Schedule findScheduleById(Integer id) {
        return adminDao.findScheduleById(id);
    }
    @Override
    public void update(Schedule schedule){
        adminDao.updateSchedule(schedule);
    }

    @Override
    public Schedule findScheduleByDoctorId(Integer doctor_id) {
        return adminDao.findScheduleByDoctorId(doctor_id);
    }




    //  挂号管理
    @Override
    public List<Registration> getRegistrationsByPatient_id(int patient_id) {
        return adminDao.findRegistrationsByPatient_id(patient_id);
    }

    //  检查项目管理
    @Override
    public List<CheckItem> findAllCheckItems() {
        return adminDao.findAllCheckItems();
    }

    @Override
    public CheckItem findCheckItemById(Integer id) {
        return adminDao.findCheckItemById(id);
    }

    @Override
    public void saveCheckItem(CheckItem item) {
        adminDao.saveCheckItem(item);
    }

    @Override
    public void updateCheckItem(CheckItem item) {
        adminDao.updateCheckItem(item);
    }

    @Override
    public void deleteCheckItemById(Integer id) {
        adminDao.deleteCheckItemById(id);
    }

    @Override
    public List<CheckItem> findCheckItemsByNameAndDepartment(String name, String department) {
        return adminDao.findCheckItemsByNameAndDepartment(name, department);
    }

    @Override
    public List<Doctor> findDoctorsByDepartment(String department) {
        return adminDao.findDoctorsByDepartment(department);
    }

}
